package bzapps.weynak;

import java.util.ArrayList;

import android.app.Dialog;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.view.Window;
import android.widget.TextView;

import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.MapView;
import com.google.android.maps.OverlayItem;

public class NoteOverlay extends ItemizedOverlay<OverlayItem>
{
	private ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>();
	private Context mContext;
	String date, client;

 public NoteOverlay(Drawable defaultMarker, Context context, String d, String user)
 {
	 super(boundCenter(defaultMarker));
	 mContext = context;
	 date = d;
	 client = user;
 }

 @Override
 public void draw(Canvas canvas, MapView mapView, boolean shadow) {
 	// TODO Auto-generated method stub
 	super.draw(canvas, mapView, false);
 }
 
 public void addOverlay(OverlayItem overlay)
 {
	 mOverlays.add(overlay);
	 populate();
 }
 @Override
 protected OverlayItem createItem(int i)
 {
	 return mOverlays.get(i);
 }
 @Override
 public int size()
 {
	 return mOverlays.size();
 }
 @Override
 protected boolean onTap(int index)
 {
	 
	 Dialog mydialog = new Dialog(mContext);
	 mydialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
	 mydialog.setContentView(R.layout.note_layout);
	 OverlayItem item = mOverlays.get(index);
	 TextView title = (TextView)mydialog.findViewById(R.id.note_layout_title);
	 TextView desc = (TextView)mydialog.findViewById(R.id.note_layout_desc);
	 TextView client = (TextView)mydialog.findViewById(R.id.note_layout_clientid);
	 TextView date = (TextView)mydialog.findViewById(R.id.note_layout_date);
	 title.setText(item.getTitle());
	 desc.setText(item.getSnippet()); 
	 client.setText(this.client);
	 date.setText(this.date);

	 mydialog.show();

	return true;
 }
}